home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-05-11 | 3.7 KB | 144 lines | [TEXT/MMCC] |
- //==================================================================
- // mac_wt.h <tur 01-May-94>
- //
- // Macintosh interface for Chris Laurel's "wt" demo.
- //
- // Comments, Bug Reports/Fixes, etc, to turly@isltd.insignia.com
- //
- //==================================================================
-
- #pragma once
-
- #ifndef macintosh
- #define macintosh
- #endif
-
- #ifndef BIGEND
- #define BIGEND
- #endif
-
- #ifndef __TYPES__
- #include "Types.h"
- #endif
- #define GotFalseTrueBoolean
- enum {False, True}; // Boolean is already defined in Mac's "Types.h"
-
-
- /**/
-
- #define PATH_MAX 80
-
- #define main WTMain
- extern int WTMain(int argc, char **argv); /* The "wt" main procedure */
-
- /**/
-
- #define _exit(x) fatal_error("_exit(%d) called", x)
-
- /**/
-
- #if __MWERKS__
- #define GOT_INLINE 1 /* MWERKS can use "inline" */
- #endif
-
-
- #define HostIndexFromPCIndex(pcIndx) (pxIndx+1)
- #define HostDirFileStr ":wt:%s:%s"
- #define HostFixupPixelData(a, b) MacFixupPixelData(a, b)
-
- extern void MacFixupPixelData(unsigned char *buf, int nBytes);
-
-
- /* Use inline 68K assembly for Fixed and Fract muls/divs */
-
- #if !defined(USES68KINLINES) && (defined(THINK_C) || defined(applec))
-
- // MPW C unfortunately gives code generation errors if we have any
- // of these long inline assembly routines. Bit sad, really.
-
- #if !defined(applec)
- #define USES68KINLINES 1
- #endif
- #define ONEWORDINLINE(a) = a
- #endif
-
-
- #if USES68KINLINES
-
- #pragma parameter __D0 mc68k_fixmul(__D0, __D1)
- extern long mc68k_fixmul(long a, long b) = {0x4C01, 0x0C01, 0x3001, 0x4840};
- /* mc68k_fixmul: "muls.l d0, d1:d0", "move.w d1, d0", "swap d0" */
-
- #pragma parameter __D0 mc68k_fixdiv(__D2, __D1)
- extern long mc68k_fixdiv(long num, long denom)
- = {0x3002, 0x4840, 0x4240, 0x4842, 0x48C2, 0x4C41, 0x0C02};
- /* "move.w d2,d0", "swap d0", "clr.w d0", "swap d2", "ext.l d2", "divs.l d1, d2:d0" */
-
- #pragma parameter __D0 mc68k_fixmul2_30(__D0, __D1)
- extern long mc68k_fixmul2_30(long a, long b)
- = {0x4C01, 0x0C01, 0xE589, 0xE598, 0x0280, 0x0000, 0x0003, 0x8081};
- /* "muls.l d1, d1:d0", "lsl.l #2, d1", "rol.l #2, d0", "and.l #3, d0", "or.l d1, d0" */
- /* We could probably lose the top two bits of D0 after the MULS.L without much effect,
- ** but I'll leave them in for the time being...
- */
-
- #else /* USES68KINLINES */
-
- extern long mc68k_fixmul(long a, long b);
- extern long mc68k_fixdiv(long num, long denom);
- extern long mc68k_fixmul2_30(long a, long b);
-
- #endif /* USES68KINLINES */
-
-
- #define PARANOID
-
-
- /* We can either use our own handcrafted fixedpoint routines (e.g., above)
- ** or we can use those provided in the base (which basically correspond to
- ** lots of floating point expressions.)
- **
- ** With Metrowerks, the floating point stuff is faster than calling the
- ** Mac Toolbox _FixMul, _FixDiv, etc (!) This could be because these calls
- ** are emulated or (more likely) the 601 likes floating point ops more than
- ** subroutine call/returns! Must look into this sometime.
- **
- ** For this reason, I've made the use of the Mac's 'handcrafted' routines (our
- ** own or _FixMul in the ROM) dependent on a define, "USE_HOST_FIXEDPOINT".
- **
- ** Currently, this will only be used if we're on a 68K box, but feel free to
- ** experiment!
- */
-
- #if !__powerc
- #define USE_HOST_FIXEDPOINT
- #endif
-
- #ifdef USE_HOST_FIXEDPOINT
-
- #if __powerc || applec
- #define DONT_USE_ASM_FIXEDPOINT 1
- #endif
-
- #if DONT_USE_ASM_FIXEDPOINT
- #ifndef __FIXMATH__
- #include <FixMath.h>
- #endif
- #ifndef __TOOLUTILS__
- extern pascal Fixed FixMul(Fixed a, Fixed b) ONEWORDINLINE(0xA868);
- #endif
-
- #define fixmul(a, b) FixMul(a, b)
- #define fixdiv(a, b) FixDiv(a, b)
- #define fixmul2_30(a, b) FracMul(a, b)
-
- #else
-
- #define fixmul(a, b) mc68k_fixmul(a, b)
- #define fixdiv(n, d) mc68k_fixdiv(n, d)
- #define fixmul2_30(a, b) mc68k_fixmul2_30(a, b)
-
- #endif
- #endif /* USE_HOST_FIXEDPOINT */
-
-